﻿#pragma once

#include <string>
#include <vector>
#include "../../stringhelper.h"
#include "../../tangible_filesystem.h"

class InIReader
{
    #pragma region Fields
private:
//C# TO C++ CONVERTER WARNING: C++ has no equivalent to a 'readonly' collection which allows modification of internal state:
//ORIGINAL LINE: private readonly List<string> _contents;
    std::vector<std::string> _contents;
    const std::string _fileName;
    #pragma endregion

    #pragma region Constructor
public:
    InIReader(const std::string &fileName);
    #pragma endregion

    #pragma region Functions
private:
    std::string FindValue(const std::string &section, const std::string &key);

    int FindIndex(const std::string &section, const std::string &key);

public:
    void Save();
    #pragma endregion

    #pragma region Read
    bool ReadBoolean(const std::string &section, const std::string &key, bool Default, bool writeWhenNull = true);

    unsigned char ReadByte(const std::string &section, const std::string &key, unsigned char Default, bool writeWhenNull = true);

    signed char ReadSByte(const std::string &section, const std::string &key, signed char Default, bool writeWhenNull = true);

    unsigned short ReadUInt16(const std::string &section, const std::string &key, unsigned short Default, bool writeWhenNull = true);

    short ReadInt16(const std::string &section, const std::string &key, short Default, bool writeWhenNull = true);

    unsigned int ReadUInt32(const std::string &section, const std::string &key, unsigned int Default, bool writeWhenNull = true);

    int ReadInt32(const std::string &section, const std::string &key, int Default, bool writeWhenNull = true);

    unsigned long long ReadUInt64(const std::string &section, const std::string &key, unsigned long long Default, bool writeWhenNull = true);

    long long ReadInt64(const std::string &section, const std::string &key, long long Default, bool writeWhenNull = true);

    float ReadSingle(const std::string &section, const std::string &key, float Default, bool writeWhenNull = true);

    double ReadDouble(const std::string &section, const std::string &key, double Default, bool writeWhenNull = true);

    Decimal ReadDecimal(const std::string &section, const std::string &key, Decimal Default, bool writeWhenNull = true);

    std::string ReadString(const std::string &section, const std::string &key, const std::string &Default, bool writeWhenNull = true);

    char ReadChar(const std::string &section, const std::string &key, char Default, bool writeWhenNull = true);

    Point *ReadPoint(const std::string &section, const std::string &key, Point *Default);

    Size *ReadSize(const std::string &section, const std::string &key, Size *Default);

    TimeSpan ReadTimeSpan(const std::string &section, const std::string &key, TimeSpan Default);

    float ReadFloat(const std::string &section, const std::string &key, float Default);
    #pragma endregion

    #pragma region Write
    void Write(const std::string &section, const std::string &key, bool value);

    void Write(const std::string &section, const std::string &key, unsigned char value);

    void Write(const std::string &section, const std::string &key, signed char value);

    void Write(const std::string &section, const std::string &key, unsigned short value);

    void Write(const std::string &section, const std::string &key, short value);

    void Write(const std::string &section, const std::string &key, unsigned int value);

    void Write(const std::string &section, const std::string &key, int value);

    void Write(const std::string &section, const std::string &key, unsigned long long value);

    void Write(const std::string &section, const std::string &key, long long value);

    void Write(const std::string &section, const std::string &key, float value);

    void Write(const std::string &section, const std::string &key, double value);

    void Write(const std::string &section, const std::string &key, Decimal value);

    void Write(const std::string &section, const std::string &key, const std::string &value);

    void Write(const std::string &section, const std::string &key, char value);

    void Write(const std::string &section, const std::string &key, Point *value);

    void Write(const std::string &section, const std::string &key, Size *value);

    void Write(const std::string &section, const std::string &key, TimeSpan value);
    #pragma endregion
};
